package com.cn.customer.housekeeping.housekeepingb.ui.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import com.cn.customer.housekeeping.housekeepingb.R;
import com.cn.customer.housekeeping.housekeepingb.bean.FriendRequestListResp;
import com.cn.customer.housekeeping.housekeepingb.ui.base.QuickAdapter;
import com.cn.customer.housekeeping.housekeepingb.ui.helper.ItemHelper;
import com.lfq.pulltorefresh.library.PullToRefreshBase;
import com.lfq.pulltorefresh.library.PullToRefreshListView;

import java.util.ArrayList;
import java.util.List;


public class MerchandiseListBaseFragment extends Fragment {
   RecyclerView swipeTarget;//

    public int type;
    private boolean isPrepared = false;

    private ListView mListView;
    private PullToRefreshListView mPullToRefreshListView;
    private int pageNum = 1;
    private int pageSize = 20;
    private QuickAdapter<FriendRequestListResp> mAdapter;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View mView = inflater.inflate(R.layout.activity_main_list, container, false);


        mPullToRefreshListView = (PullToRefreshListView) mView. findViewById(R.id.pull_refresh_list);
        mPullToRefreshListView.setMode(PullToRefreshBase.Mode.DISABLED);
        mListView = mPullToRefreshListView.getRefreshableView();
        mListView.setHeaderDividersEnabled(false);
        mListView.setDividerHeight(0);
        ItemHelper mItemHelper = new ItemHelper();
        mAdapter = mItemHelper.setAdapteMerchandise(getActivity(), new ArrayList());
        mListView.setAdapter(mAdapter);


        List<FriendRequestListResp> list = new ArrayList();
        list.add(new FriendRequestListResp());
        list.add(new FriendRequestListResp());
        list.add(new FriendRequestListResp());
        list.add(new FriendRequestListResp());
        list.add(new FriendRequestListResp());
        mAdapter.replaceAll(list);
        return mView;
    }
    //统一的Fragment构建方法
    public static MerchandiseListBaseFragment newInstance(int flag) {
        Bundle args = new Bundle();
        //type代表页签，0：全部订单 1：待发货 2：待收货 3：已完成
        args.putString("type", String.valueOf(flag));
        MerchandiseListBaseFragment fragment = new MerchandiseListBaseFragment();
        fragment.setArguments(args);
        return fragment;
    }
}
